<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	<title>ShieldJS2 Source: shield.util.js</title>

	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">

	<link type="text/css" rel="stylesheet" href="styles/site.Cerulean.css">

</head>

<body>

<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container">
	<div class="navbar-header">
		<a class="navbar-brand" href="index.html">ShieldJS2</a>
		<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
        </button>
	</div>
	<div class="navbar-collapse collapse" id="topNavigation">
		<ul class="nav navbar-nav">
			
			<li class="dropdown">
				<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="ShieldJS.core._defaults.html">ShieldJS.core._defaults</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="$().contentChange.html">$().contentChange</a></li><li><a href="$().insertAtCursor.html">$().insertAtCursor</a></li><li><a href="$().resize.html">$().resize</a></li><li><a href="$().selection.html">$().selection</a></li><li><a href="$().serializeJson.html">$().serializeJson</a></li><li><a href="$().shieldBindHtmlAction.html">$().shieldBindHtmlAction</a></li><li><a href="$().shieldLeftMenu.html">$().shieldLeftMenu</a></li><li><a href="$().shieldMainContent.html">$().shieldMainContent</a></li><li><a href="Dialog.html">Dialog</a></li><li><a href="Map.html">Map</a></li><li><a href="ShieldJS.html">ShieldJS</a></li><li><a href="ShieldJS.ajax.html">ShieldJS.ajax</a></li><li><a href="ShieldJS.core.html">ShieldJS.core</a></li><li><a href="ShieldJS.dialog.html">ShieldJS.dialog</a></li><li><a href="ShieldJS.form.html">ShieldJS.form</a></li><li><a href="ShieldJS.HtmlAction.html">ShieldJS.HtmlAction</a></li><li><a href="ShieldJS.HtmlAction.HTMLEleActions.html">ShieldJS.HtmlAction.HTMLEleActions</a></li><li><a href="ShieldJS.HtmlAction.successDo.html">ShieldJS.HtmlAction.successDo</a></li><li><a href="ShieldJS.HtmlAction.successDoMethod.html">ShieldJS.HtmlAction.successDoMethod</a></li><li><a href="String.replaceAll.html">String.replaceAll</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="global.html#dateFormat">dateFormat</a></li><li><a href="global.html#ele">ele</a></li><li><a href="global.html#findAndMarkEle">findAndMarkEle</a></li><li><a href="global.html#findAndMarkEleOn">findAndMarkEleOn</a></li><li><a href="global.html#findEle">findEle</a></li><li><a href="global.html#formatUrl">formatUrl</a></li><li><a href="global.html#getExtendSettings">getExtendSettings</a></li><li><a href="global.html#getjQueryObj">getjQueryObj</a></li><li><a href="global.html#getJSDir">getJSDir</a></li><li><a href="global.html#getJSPath">getJSPath</a></li><li><a href="global.html#getParams">getParams</a></li><li><a href="global.html#getRandomColor">getRandomColor</a></li><li><a href="global.html#getSettings">getSettings</a></li><li><a href="global.html#getTimeAttr">getTimeAttr</a></li><li><a href="global.html#hasAttr">hasAttr</a></li><li><a href="global.html#height">height</a></li><li><a href="global.html#index">index</a></li><li><a href="global.html#jQObjEmpty2Null">jQObjEmpty2Null</a></li><li><a href="global.html#openNewPage">openNewPage</a></li><li><a href="global.html#paramNameAdapt">paramNameAdapt</a></li><li><a href="global.html#preEle">preEle</a></li><li><a href="global.html#preEleIndex">preEleIndex</a></li><li><a href="global.html#printCallStack">printCallStack</a></li><li><a href="global.html#removeHtml">removeHtml</a></li><li><a href="global.html#replaceParamVal">replaceParamVal</a></li><li><a href="global.html#title">title</a></li><li><a href="global.html#width">width</a></li>
				</ul>
			</li>
			
		</ul>
        
            <div class="col-sm-3 col-md-3">
                <form class="navbar-form" role="search">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
                        <div class="input-group-btn">
                            <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
                        </div>
                    </div>
                </form>
            </div>
        
	</div>

</div>
</div>


<div class="container" id="toc-content">
<div class="row">

	
	<div class="col-md-12">
	
		<div id="main">
			

		<h1 class="page-title">Source: shield.util.js</h1>
    
<section>
    <article>
        <pre
            class="sunlight-highlight-javascript linenums">/*工具*/
;(function($){
	/**
	 * 序列表单内容为json对象
	 * @constructor $().serializeJson
	 * @author kevin Lv
	 * @returns {Json} json对象
	 * @example $("form").serializeJson() 
	 * 
	 */
	$.fn.serializeJson = function(){
		var serializeObj = {};  
		var array = this.serializeArray();
		var str = this.serialize();
		$(array).each(function(){
			if(serializeObj[this.name] || serializeObj[this.name]===""){ //空字符串会处理为null
				if($.isArray(serializeObj[this.name])){
					serializeObj[this.name].push(this.value);
				} else {
					serializeObj[this.name] = [serializeObj[this.name],this.value];
				}
			}else{
				serializeObj[this.name] = this.value;
			}
		});
		return serializeObj;
	};
	/**
	 * 动态监听内容变化
	 * @constructor $().contentChange
	 * @author kevin Lv
	 * @param selector {String} jQuery选择器
	 * @param callbackFn {Function} 回调函数
	 * @example $("body").contentChange("body", function(){}); 
	 * 
	 */
	$.fn.contentChange= function(selector, callbackFn){
		/**
		* @description 处理函数
		*/
		this.each(function(){
			var containerE = $(this); 
			containerE.on('DOMNodeInserted', selector, function(){ //ie8以上支持
				callbackFn($(this));
			});
		});
	};
})(jQuery);
/**
 * resize增强版（默认只有浏览器窗口调整大小，修改后可监听div或其它元素）
 * @constructor $().resize
 * @author 来自网络
 * @param callbackFn {Function} 回调函数
 * @example $("#div1").resize(function(){}); 
 * 
 */
;(function($, h, c) {
	var a = $([]), e = $.resize = $.extend($.resize, {}), i, k = "setTimeout", j = "resize", d = j
			+ "-special-event", b = "delay", f = "throttleWindow";
	e[b] = 350;
	e[f] = true;
	$.event.special[j] = {
		setup : function() {
			if (!e[f] &amp;&amp; this[k]) {
				return false
			}
			var l = $(this);
			a = a.add(l);
			$.data(this, d, {
				w : l.width(),
				h : l.height()
			});
			if (a.length === 1) {
				g()
			}
		},
		teardown : function() {
			if (!e[f] &amp;&amp; this[k]) {
				return false
			}
			var l = $(this);
			a = a.not(l);
			l.removeData(d);
			if (!a.length) {
				clearTimeout(i)
			}
		},
		add : function(l) {
			if (!e[f] &amp;&amp; this[k]) {
				return false
			}
			var n;
			function m(s, o, p) {
				var q = $(this), r = $.data(this, d);
				r.w = o !== c ? o : q.width();
				r.h = p !== c ? p : q.height();
				n.apply(this, arguments)
			}
			if ($.isFunction(l)) {
				n = l;
				return m
			} else {
				n = l.handler;
				l.handler = m
			}
		}
	};
	function g() {
		i = h[k](function() {
			a.each(function() {
				var n = $(this), m = n.width(), l = n.height(), o = $
						.data(this, d);
				if (m !== o.w || l !== o.h) {
					n.trigger(j, [ o.w = m, o.h = l ])
				}
			});
			g()
		}, e[b])
	}
})(jQuery, this);
/**
 * 将值插入到光标位置
 * @constructor $().insertAtCursor
 * @author 来自网络
 * @param myValue {String} 赋值
 * @example $("#div1").insertAtCursor('123');
 * 
 */
$.fn.extend({
    insertAtCursor : function(myValue) {
    	var $t = $(this)[0];
		if (document.selection) {
			this.focus();
			sel = document.selection.createRange();
			sel.text = myValue;
			this.focus();
		} else if ($t.selectionStart || $t.selectionStart == '0') {
			var startPos = $t.selectionStart;
			var endPos = $t.selectionEnd;
			var scrollTop = $t.scrollTop;
			$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
			this.focus();
			$t.selectionStart = startPos + myValue.length;
			$t.selectionEnd = startPos + myValue.length;
			$t.scrollTop = scrollTop;
		} else {
			this.value += myValue;
			this.focus();
		}
	}
});
/**
 * 获取选中元素对象（对象中包含开始位置、结束位置、内容）
 * @constructor $().selection
 * @author 来自网络
 * @example $("#div1").selection().text; 
 * 
 */
$.fn.selection = function(){
	var s,e,range,stored_range;
	if (this[0].selectionStart == undefined) {
		var selection=document.selection;
		if (this[0].tagName.toLowerCase() != "textarea") {
			var val = this.val();
			range = selection.createRange().duplicate();
			range.moveEnd("character", val.length);
			s = (range.text == "" ? val.length:val.lastIndexOf(range.text));
			range = selection.createRange().duplicate();
			range.moveStart("character", -val.length);
			e = range.text.length;
		} else {
			range = selection.createRange(),
			stored_range = range.duplicate();
			stored_range.moveToElementText(this[0]);
			stored_range.setEndPoint('EndToEnd', range);
			s = stored_range.text.length - range.text.length;
			e = s + range.text.length;
		}
	} else {
		s=this[0].selectionStart,
		e=this[0].selectionEnd;
	}
	var te=this[0].value.substring(s,e);
	return {start:s, end:e, text:te};
};
/**
 * Map对象
 * @constructor Map
 * @author kevin Lv
 * @example  示例：
 * var myMap = new Map();
 * myMap.put("key","value");
 * var key = myMap.get("key");
 * myMap.remove("key");
 * 
 */
function Map(){

	this.elements = new Array();
	
	this.size = function(){
		return this.elements.length;
	}
	
	this.isEmpty = function(){
		return (this.elements.length &lt; 1);
	}
	
	this.clear = function(){
		this.elements = new Array();
	}
	
	this.put = function(_key, _value){
		this.remove(_key);
		this.elements.push({key: _key, value: _value});
	}
	
	this.remove = function(_key){
		try {
			for (i = 0; i &lt; this.elements.length; i++) {
				if (this.elements[i].key == _key) {
					this.elements.splice(i, 1);
					return true;
				}
			}
		} catch (e) {
			return false;
		}
		return false;
	}
	
	this.get = function(_key){
		try {
			for (i = 0; i &lt; this.elements.length; i++) {
				if (this.elements[i].key == _key) { return this.elements[i].value; }
			}
		} catch (e) {
			return null;
		}
	}
	
	this.element = function(_index){
		if (_index &lt; 0 || _index >= this.elements.length) { return null; }
		return this.elements[_index];
	}
	
	this.containsKey = function(_key){
		try {
			for (i = 0; i &lt; this.elements.length; i++) {
				if (this.elements[i].key == _key) {
					return true;
				}
			}
		} catch (e) {
			return false;
		}
		return false;
	}
	
	this.values = function(){
		var arr = new Array();
		for (i = 0; i &lt; this.elements.length; i++) {
			arr.push(this.elements[i].value);
		}
		return arr;
	}
	
	this.keys = function(){
		var arr = new Array();
		for (i = 0; i &lt; this.elements.length; i++) {
			arr.push(this.elements[i].key);
		}
		return arr;
	}
}
/**
 * Dialog对象
 * @constructor Dialog
 * @author kevin Lv
 * @example  示例：
 * var dialog = new Dialog();
 * dialog.put(ele, index, width, height, preEle, preEleIndex);
 * 
 */
function Dialog(){
	/**	弹出框元素对象
		@type jQueryObject
	 */
	this.ele = {};
	/**	下标
		@type int
	 */
	this.index = -1;
	/**	宽度
		@type int
	 */
	this.width = 0;
	/**	高度
		@type int
	 */
	this.height = 0;
	/**	上一个弹出框元素下标
		@type jQueryObject
	 */
	this.preEleIndex = null;
	/**	上一个弹出框元素
		@type jQueryObject
	 */
	this.preEle = null;
	/**	标题
		@type String
	 */
	this.title = "";

	this.init = function (ele, index, width, height, preEle, preEleIndex){
		ele.data("index", index);
		this.ele = ele;
		if (index) {
			this.index = index;
		}
		if (width) {
			this.width = width;
        } else {
        	this.width = ele.width();
		}
		if (height) {
			this.height = height;
		} else {
        	this.height = ele.height();
		}
		if (preEleIndex) {
			this.preEleIndex = preEleIndex;
        }
		this.preEle = preEle;
	}
}
/**
 * 根据传入字符串返回jQuery对象，如果本身为jquery对象直接返回
 * @param selector {Object} jQuery对象或者jQuery选择器
 * @returns {jQueryObject} jQuery对象
 */
function getjQueryObj(selector){
	if (selector) {
		if(!(selector instanceof jQuery)){ 
			selector = $(selector);
		}
    }
	return jQObjEmpty2Null(selector);
}
/**
 * 是否存在属性
 * @param jobj {jQueryObject} 判断的对象
 * @param attrname {String} 属性名
 * @returns {Boolean} 存在该属性则返回true，否则返回false
 */
function hasAttr(jobj, attrname){
	if(!jobj){
		return false;
	}
	return typeof(jobj.attr(attrname))!="undefined";
}
/**
 * 获取一个jQuery对象的扩展设置（取属性shieldSettings的设置值覆盖，不存在则取jQuery.data()设置的属性，）
 * @param ele {jQueryObject} 待处理的对象
 * @param _default {Json} 默认设置
 * @returns {Json} 参数设置
 */
function getExtendSettings(ele, _default){
	_default = _default||{};
	var settings = getParams(ele, {}, "shieldSettings");
	return $.extend(true, _default, ele.data(), settings);
};
/**
 * 获取一个jQuery对象的设置（取属性shieldSettings的设置值）
 * @param ele {jQueryObject} 待处理的对象
 * @param _default {Json} 默认设置
 * @returns {Json} 参数设置
 */
function getSettings(ele, _default){
	var settings = getParams(ele, _default||{}, "shieldSettings");
	return settings;
};
/**
 * 获取参数
 * @param ele {jQueryObject} 待处理的对象
 * @param params {Json} 默认设置
 * @param attrName {String} 属性名
 * @returns {Json} 参数设置
 */
function getParams(ele, params, attrName){
	try {
		if (!attrName) {
			attrName = "shieldParams";
        }
		if (hasAttr(ele, attrName)) { //有参数时从shieldParams取
			params = $.metadata ? $.extend({}, params, ele.metadata({ 
				"type": "attr","name": attrName, "single":attrName
			})) : params;
		} else { //无参数时默认从class取
			params = $.metadata ? $.extend({}, params, ele.metadata()) : params;
		}
		return params;
	} catch (e) {
		var name = ele.attr("name");
		if (!name) {
			name = ele.val();
        }
		alert("获取参数异常："+name+" "+e);
        return false;
	}
};
/**
 * 获取时间参数，转换为毫秒
 * @param  ele {jQueryObject} 待处理的对象
 * @param  attrName {String} 属性名
 * @param  defaultValue {Number} 默认值
 * @returns {Number} 时间值
 */
function getTimeAttr(ele, attrName, defaultValue){
	var time = defaultValue;
	if (hasAttr(ele, attrName)) {
		var timeSrc = ele.attr(attrName).toLowerCase();
		var time = parseFloat(timeSrc);
		time = time*1000; //默认是秒
		if (timeSrc.indexOf("m") != -1 || timeSrc.indexOf("min") != -1) {
			time = time*60; //分钟，1min=60s
		}
		if (timeSrc.indexOf("h") != -1 || timeSrc.indexOf("hour") != -1) {
			time = time*3600; //小时，1h=3600s
		}
    }
	return time;
};
/**
 * 全部替换，默认替换只替换第1个
 * @constructor String.replaceAll
 * @param s1 {String} 替换前字符串
 * @param s2 {String} 替换后字符串
 * @returns {String} 
 */
String.prototype.replaceAll = function(s1, s2){
	//gm g=global, m=multiLine
	return this.replace(new RegExp(s1,"gm"),s2);
}
/**
 * 获取并标记获取到的元素，防止重复添加
 * @param  ele {jQueryObject} 待处理的父对象
 * @param selector {String} 选择器
 * @see {@link findEle} 注意区别
 * @returns {jQueryObject}
 */
function findAndMarkEle(ele, selector) {
	var markSelector = selector.replaceAll(" ","").replaceAll("\\.","_").replaceAll("#","_sdc01_").replaceAll("\\:","_sdc02_").replaceAll(">","_sdc03_")
	.replaceAll("\\+","_sdc04_").replaceAll("\\~","_sdc05_").replaceAll("=","_sdc06_").replaceAll("\\!","_sdc07_").replaceAll("\\^","_sdc08_")
	.replaceAll("\\$","_sdc09_").replaceAll("\\*","_sdc10_").replaceAll("\\[","_sdc11_").replaceAll("\\]","_sdc12_").replaceAll("\\(","_sdc13_")
	.replaceAll("\\)","_sdc14_").replaceAll("'","_sdc15_").replaceAll("\"","_sdc16_").replaceAll(",","_sdc17_");
//	var ele = ele.find(selector + ":not(.shieldMarked"+markSelector+",.noshield)"); //此写法在selector为多重选择器时有问题，如弹出框.shieldDialog,.shieldLookup
	var ele = ele.find(selector).not(".shieldMarked"+markSelector+",.noshield");
	ele.addClass("shieldMarked"+markSelector);
	ele.data("shieldMarked"+markSelector, "marked");
	return ele;
};
//
/**
 * 获取但不标记取到的元素
 * @param ele {jQueryObject} 待处理的父对象
 * @param selector {String} 选择器
 * @see {@link findAndMarkEle} 注意区别
 * @see {@link findAndMarkEleOn} 注意区别
 * @returns {jQueryObject}
 */
function findEle(ele, selector) {
	var ele = ele.find(selector + ":not(.noshield)");
	return ele;
};
/**
 * 获取并标记元素，动态绑定事件(待完善)
 * @param ele {jQueryObject} 待处理的父对象
 * @param selector {String} 一个选择器字符串用于过滤器的触发事件的选择器元素的后代。如果选择的为null或省略，当它到达选定的元素，事件总是触发。
 * @param events {String} 一个或多个用空格分隔的事件类型和可选的命名空间，如"click"或"keydown.myPlugin" 。
 * @see {@link findAndMarkEle} 注意区别
 * @returns {jQueryObject}
 */
function findAndMarkEleOn(ele, selector, events) {
	var ele = findAndMarkEle(ele, selector);
	
	ele.off(events, selector).on(events, selector, function(event){
		var shieldForwardEle = $(this);
		if (hasAttr(shieldForwardEle,"toShieldMenu")) { //有菜单属性才处理
			var toShieldMenuArr = shieldForwardEle.attr("toShieldMenu").split(">");
			if (toShieldMenuArr.length > 1) {
				var toNavMenu = $(toShieldMenuArr[0]);
				shieldForwardEle.attr("showclass",toShieldMenuArr[1]); //添加属性，跳转完成后移除
				toNavMenu.click();
			}
		}
	});
	
	return ele;
};
/**
 * 格式化url，处理为标准格式的url
 * @param url {String} 待处理的url
 * @returns {String}
 */
var formatUrl = function(url) {
    if (!url || url == '/') {
        return '';
    }
    if (url.indexOf('http://') == 0 || url.indexOf('https://') == 0) {
        return url;
    }
    if(url.indexOf('/') == 0){ //本地路径
    	return url;
    }else{
    	return 'http://' + url;
    }
};
/**
 * 打开新页面
 * @param ele {jQueryObject} 待处理的对象
 * @param href {String} 超链接
 * @param params {Json} 参数
 */
var openNewPage = function(ele, href, params) {
	var formEs = ele.closest("form");
	if (formEs.length > 0) {
		ele = formEs; //包含在form内时需要插入到form外部，否则提交的是父form
    }
	var html = "&lt;form action='" + href + "' target='_blank' method='POST'>";
	for(var key in params){
		if($.isArray(params[key])){
			for(var i=0;i&lt;params[key].length;i++) {
				html += "&lt;input type='hidden' name='" + key + "' value='" + params[key][i] + "'>"; //直接取是逗号连接的字符串
            }
		} else {
			html += "&lt;input type='hidden' name='" + key + "' value='" + params[key] + "'>";
		}
	}
	html+= "&lt;/form>";
	ele.after(html);
	var formE = ele.next();
	formE.submit(function(){
		return true;
	}).submit(); //直接用a.click()不执行
	formE.remove();
}
/**
 * 替换指定传入参数的值, paramName为参数, replaceWith为新值
 * @param oUrl {String} 待处理的url
 * @param paramName {String} 处理参数
 * @param replaceWith {String} 参数处理后的值
 * @returns {String}
 */
function replaceParamVal(oUrl, paramName, replaceWith) {
    var re = eval('/('+ paramName+'=)([^&amp;]*)/gi');
    var nUrl = oUrl.replace(re, paramName+'='+replaceWith);
    return nUrl;
}
/**
 * 日期格式化（待删除，改为moment.js）
 * @param date {Date} 带格式话的日期
 * @param format {String} 格式化的表达式，如：yyyy-MM-dd
 * @returns {String}
 */
var dateFormat = function(date, format) {
	if (format === undefined) {
		format = date;
		date = new Date();
	}
	var map = {
		"M" : date.getMonth() + 1, // 月份
		"d" : date.getDate(), // 日
		"H" : date.getHours(), // 小时
		"h" : date.getHours(), // 小时
		"m" : date.getMinutes(), // 分
		"s" : date.getSeconds(), // 秒
		"q" : Math.floor((date.getMonth() + 3) / 3), // 季度
		"S" : date.getMilliseconds()
	// 毫秒
	};
	format = format.replace(/([yMdHhmsqS])+/g, function(all, t) {
		var v = map[t];
		if (v !== undefined) {
			if (all.length > 1) {
				v = '0' + v;
				v = v.substr(v.length - 2);
			}
			return v;
		} else if (t === 'y') {
			return (date.getFullYear() + '').substr(4 - all.length);
		}
		return all;
	});
	return format;
};
/**
 * 参数名适配,返回json格式，键为源字段名值为目标字段名
 * @param ele {jQueryObject} 待处理的对象
 * @returns {Map}
 */
var paramNameAdapt = function(ele) {
	var paramAdapter = ele.attr("paramAdapter");
	var params = {};
	if (paramAdapter) { //有值且不为空
		//paramAdapter="id>typeId#newsType"
		var paramAdapters = paramAdapter.split("#"); //#号分隔
		for(var i=0;i&lt;paramAdapters.length;i++){
			var paramName = paramAdapters[i];
			if (paramName.indexOf(">")!=-1) {
				var paramNames = paramName.split(">"); //如果key与提交不一致用>号分隔
				var sourceName = paramNames[0];
				var targetName = paramNames[1];
				params[sourceName] = targetName;
			} else {
				params[paramName] = paramName;
			}
		}
	}
	return params;
}
/**
 * 判断jquery空对象转换为null，其他的原样返回
 * @param ele {jQueryObject} 待处理的对象
 * @returns {jQueryObject}
 */
var jQObjEmpty2Null = function(ele) {
	if (!ele || ele.length == 0) {
	    return null;
    }
	return ele;
}
/**
 * 移除字符串中的html字符
 * @param str {String} 待处理的字符
 * @returns {String}
 */
var removeHtml = function(str) {
	return jQuery("&lt;p>"+str+"&lt;/p>").text();
}
/**
 * 随机取色
 * @returns {String} 16进制表示的颜色字符串
 */
var getRandomColor = function(){
	return  '#' + (function(color){
    	return (color +=  '0123456789abcdef'[Math.floor(Math.random()*16)])
      	&amp;&amp; (color.length == 6) ?  color : arguments.callee(color);
  	})('');
}
/**
 * 打印堆栈信息
 * @returns {String}
 */
function printCallStack() {
	var stackStr = "";
	if (console &amp;&amp; console.trace){ //ie8下不支持trace
		console.trace();
	}
	return stackStr;
}
/**
 * 返回当前js的路径
 * @returns {String}
 */
function getJSPath(){
	var currentScript=document.currentScript?document.currentScript.src:function(){
		var jssrc;
		var jss=document.scripts;
		for(var i=jss.length-1,n=i;n>0;n--){
			alert(1);
			if("interactive"===jss[n].readyState){ //已经加载
				jssrc=jss[n].src;
				break;
			}
			return jssrc||jss[i].src
		}
	}();
	return currentScript;
}
/**
 * 返回当前js的目录
 * @returns {String}
 */
function getJSDir(){
	var jsPath = getJSPath();
	return jsPath.substring(0,jsPath.lastIndexOf("/")+1)
}
//ie8不支持isArray的方法
if (!Array.isArray) {
	Array.isArray = function(arg) {
		return Object.prototype.toString.call(arg) === '[object Array]';
	};
}
</pre>
    </article>
</section>





		</div>
	</div>

	<div class="clearfix"></div>

	

</div>
</div>


    <div class="modal fade" id="searchResults">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">Search results</h4>
          </div>
          <div class="modal-body"></div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div>


<footer>


	<span class="copyright">
	ShieldJS2 Copyright © 2018-2019 基于JSDoc3 and DocStrap生成的JsDoc说明文档.
	</span>

<span class="jsdoc-message">
	Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
	
		on Mon Dec 16th 2019
	
	using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>

<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>

    <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>


<script>
$( function () {
	$( "[id*='$']" ).each( function () {
		var $this = $( this );

		$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
	} );

	$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
		var $this = $( this );

		var example = $this.find( "code" );
		exampleText = example.html();
		var lang = /{@lang (.*?)}/.exec( exampleText );
		if ( lang && lang[1] ) {
			exampleText = exampleText.replace( lang[0], "" );
			example.html( exampleText );
			lang = lang[1];
		} else {
			var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
			lang = langClassMatch ? langClassMatch[1] : "javascript";
		}

		if ( lang ) {

			$this
			.addClass( "sunlight-highlight-" + lang )
			.addClass( "linenums" )
			.html( example.html() );

		}
	} );

	Sunlight.highlightAll( {
		lineNumbers : true,
		showMenu : true,
		enableDoclinks : true
	} );

	$.catchAnchorLinks( {
        navbarOffset: 10
	} );
	$( "#toc" ).toc( {
		anchorName  : function ( i, heading, prefix ) {
			return $( heading ).attr( "id" ) || ( prefix + i );
		},
		selectors   : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
		showAndHide : false,
		smoothScrolling: true
	} );

	$( "#main span[id^='toc']" ).addClass( "toc-shim" );
	$( '.dropdown-toggle' ).dropdown();

    $( "table" ).each( function () {
      var $this = $( this );
      $this.addClass('table');
    } );

} );
</script>



<!--Navigation and Symbol Display-->


<!--Google Analytics-->



    <script type="text/javascript">
        $(document).ready(function() {
            SearcherDisplay.init();
        });
    </script>


</body>
</html>
